package com.woniu.new_orange.finance_model_guo.controller;

import com.woniu.new_orange.entity.Refund;
import com.woniu.new_orange.entity.RefundRecord;
import com.woniu.new_orange.finance_model_guo.Vo.RefundRecordVo;
import com.woniu.new_orange.finance_model_guo.service.RefundRecordService;
import com.woniu.new_orange.personnel_model_wu.VO.RefundRvo;
import com.woniu.new_orange.personnel_model_wu.service.RefundService;
import com.woniu.new_orange.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Program: new_orange->RefoundRecordController
 * @Description: 退款记录
 * @Author: 谭少琛的爸爸
 * @Date: 2023-02-01 19:43
 * @Version： 1.0
 **/
@RestController
@RequestMapping("res")
@Api(tags = "退款记录表")
public class RefoundRecordController {
    @Resource
    private RefundRecordService recordService;
    @Resource
    private RefundService refundService;
    @ApiOperation(value = "查全部",notes = "进行查询全部")
    @GetMapping("queryAll")
    public Result query(){
        //查询
        List<RefundRecordVo> refundRecords = recordService.selectAll();

        return Result.ok().data("RefoundList",refundRecords);
    }
    @GetMapping("{id}")
    public Result add1(@PathVariable long id){
//        List<Refund> refunds = refundService.selectAll();
//        int i = refundService.insertSelective1(refund);
//         RefundRvo refund = refundService.selectRecord(id);
//
//        System.out.println(refund);
//        RefundRvo refund = refundService.selectRecord(id);
        Refund refund = refundService.selectByPrimaryKey(id);
        BigDecimal money =refund.getRefundMoney();
         Integer refundId = refund.getRefundId();
    Date refundCreateTime = refund.getRefundCreateTime();
        RefundRecord refundRecord = new RefundRecord();
        refundRecord.setRefundRecordActualMoney(money);
        refundRecord.setRefundId(refundId);
        refundRecord.setRefundRecordActualTime(refundCreateTime);

        int i = recordService.insertSelective(refundRecord);
//      List<RefundRecordVo> refundRecordVos = recordService.selectAll();

        return Result.ok();
    }
}
